package assistClass;

import java.util.concurrent.CountDownLatch;

/**
 * CountdownLaunch测试
 */
public class CountDownLaunchTest {
    public static void main(String[] args) throws InterruptedException {
        //初始数量为6
        CountDownLatch countDownLatch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"走出去了");
                countDownLatch.countDown();//计数器减一
            },String.valueOf(i)).start();
        }

        countDownLatch.await();//等待计数器归零

        System.out.println("关门");
    }
}
